function onSuccess(fileEntry) {
    alert(fileEntry.name);
}

var sync = function() {
}
 
sync.prototype.show = function(str, win, fail) {
cordova.exec(win, fail, "sync", "show", [str]);
};
 
navigator.sync = new sync();

function syncronize(ms){
	//alert(ms);
	navigator.sync.show(ms);
}

function uploadFile(imageURI) {
	//window.resolveLocalFileSystemURI("file://nature.txt", onSuccess, fail);
    var options = new FileUploadOptions();
    options.fileKey="file";
    options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
    options.mimeType="text/plain";

    var params = new Object();
    params.value1 = "test";
    params.value2 = "param";

    options.params = params;

    var uri = encodeURI("http://www.stud.hig.no/~090370/nature/file_load_txt.php");
    
    var ft = new FileTransfer();
    ft.upload(imageURI, uri, win, fail, options);
}

function uploadPhoto(imageURI) {
    var options = new FileUploadOptions();
    options.fileKey="file";
    options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
    options.mimeType="image/jpeg";

    var params = new Object();
    params.value1 = "test";
    params.value2 = "param";

    options.params = params;
    
    var uri = encodeURI("http://www.stud.hig.no/~090370/nature/file_load.php");

    var ft = new FileTransfer();
    ft.upload(imageURI, uri, win, fail, options);
}

function win(r) {
    console.log("Code = " + r.responseCode);
    console.log("Response = " + r.response);
    console.log("Sent = " + r.bytesSent);
    alert("The file has been successfully sent to the Server!");
}

function fail(error) {
    alert("An error has occurred: Code = " = error.code);
}